<template>
  <div>
     <Row>
        <input v-model="gameId" placeholder="游戏id,不填为所有游戏" ></input>
        <Select v-model="tableName" style="width:200px" not-found-text="jackpot_bouns">
          <Option v-for="item in tableList" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        <Button type="primary" @click="onSearch">查询</Button>
    </Row>
    <Table :border="true" :stripe="true" :show-header="true" :height="500" :data="tableData" :columns="tableColumns"></Table>
    <Page class="bottom-page" :total="totalPage" :current="crtPage" :page-size="pageSize" show-total show-elevator @on-change="onChange"></Page>
  </div>
</template>
<script>

import {getJackPots} from '@/api/jackpot.js'
import {getVO} from '@/common/proto-vo.js'
export default {
  data () {
    return {
      tableData: [],
      gameId: '',
      tableName: 'jackpot_bouns',
      crtPage: 1,
      totalPage: 0,
      pageSize: 10,
      tableList: [
        {
          value: 'jackpot_bouns',
          label: 'jackpot_bouns'
        },
        {
          value: 'jackpot_casino',
          label: 'jackpot_casino'
        },
        {
          value: 'jackpot_free',
          label: 'jackpot_free'
        },
        {
          value: 'jackpot_l',
          label: 'jackpot_l'
        },
        {
          value: 'jackpot_machine',
          label: 'jackpot_machine'
        },
        {
          value: 'jackpot_xl',
          label: 'jackpot_xl'
        },
        {
          value: 'jackpot_xxl',
          label: 'jackpot_xxl'
        },
        {
          value: 'jackpot_xxxl',
          label: 'jackpot_xxxl'
        }
      ]
    }
  },
  created () {
    this.onSearch()
  },
  methods: {
    onSearch () {
      let tgameId = 0
      if (this.gameId !== '') {
        tgameId = parseInt(this.gameId)
      }
      console.log('this.tableName:', this.tableName, ',tgameId:', tgameId)
      getJackPots(this.crtPage, this.pageSize, tgameId, this.tableName).then((data) => {
        if (!data) {
          return
        }
        this.tableData = []
        let JackPotVO = getVO('JackPotVO')
        let pv = data.data.data
        let len = pv.data.length
        for (let i = 0; i < len; i++) {
          let vo = JackPotVO.decode(pv.data[i])
          vo.jackpotNum = vo.jackpotNum.toFixed(5)
          vo.casinoNum = vo.casinoNum.toFixed(5)
          this.tableData.push(vo)
        }
        this.totalPage = pv.intValues[1]
        console.log(this.tableData)
      })
    },
    onChange (item) {
      console.log(item)
      this.crtPage = item
      this.onSearch()
    }
  },
  computed: {
    tableColumns () {
      let cols = [
        {
          title: '游戏Id',
          key: 'gameId',
          align: 'center'
        },
        {
          title: 'jackpotNum',
          key: 'jackpotNum',
          align: 'center'
        },
        {
          title: 'casinoNum',
          key: 'casinoNum',
          align: 'center'
        },
        {
          title: '类型',
          key: 'type',
          align: 'center'
        }
      ]
      return cols
    }
  }
}

</script>

<style scoped>
.log-str{
  font-size: 14px;
  margin-bottom: 2px;
}
.content{
  min-height: 460px;
}
.bottom-page{
  margin-top: 5px;
  margin-bottom: 10px;
  float: right;
}
</style>
